function clearForm(form) {
	// iterate over all of the inputs for the form
	// element that was passed in
	$(':input', form).each(function() {
		var type = this.type;
		var tag = this.tagName.toLowerCase(); // normalize case
		// it's ok to reset the value attr of text inputs,
		// password inputs, and textareas
		if (type == 'text' || type == 'password' || type == 'number' || type == 'tel' || type == 'email' || tag == 'textarea')
			this.value = "";
		// checkboxes and radios need to have their checked state cleared
		// but should *not* have their 'value' changed
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		// select elements need to have their 'selectedIndex' property set to -1
		// (this works for both single and multiple select elements)
		else if (tag == 'select')
			this.selectedIndex = 0;
	});
};

function getDay(n){
	var today = new Date();
	var yesterday = new Date(today);
	yesterday.setDate(today.getDate()+n); //setDate also supports negative values, which cause the month to rollover.
	
	var dd = yesterday.getDate();
	var mm = yesterday.getMonth()+1; //January is 0!
	var yyyy = yesterday.getFullYear();
	
	if(dd<10){dd='0'+dd;} 
	if(mm<10){mm='0'+mm;} 
	
	yesterday = yyyy+'-'+mm+'-'+dd;
		
	return yesterday;
}

function merge(obj1,obj2){ // Our merge function
    var result = {}; // return result
    for(i in obj1){      // for every property in obj1 
        if((i in obj2) && (typeof obj1[i] === "object") && (i !== null)){
            result[i] = merge(obj1[i],obj2[i]); // if it's an object, merge   
        }else{
           result[i] = obj1[i]; // add it to result
        }
    }
    for(i in obj2){ // add the remaining properties from object 2
        if(i in result){ //conflict
            continue;
        }
        result[i] = obj2[i];
    }
    return result;
}

function isNotNull(str){
	return (typeof str !== "undefined" && str != '' && str != null && str != 'n/a' && str != 'N/A');
}
function isNull(str){
	return (typeof str === "undefined" || str == '' || str == null || str == 'n/a' || str == 'N/A');
}